﻿using Bouyei.GeoCore.Converters;
using Bouyei.GeoCore.Geometries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bouyei.GeoCore.GeoParsers.EsriJson
{
    public class GeometryReader:BaseString
    {
        public GeoType GeometryType { get; set; }

        public GeometryReader(string geojson)
        :base(geojson) { }

        public Geometry Reader()
        {
            if (Content.Contains("rings"))
            {
                var geo = new EsriJsonPolygon(Content).ToGeometry();
                GeometryType = geo.GeometryType;
                return geo;
            }
            else if (Content.Contains("paths"))
            {
                var geo=new EsriJsonLineString(Content).ToGeometry();
                GeometryType = geo.GeometryType;
                return geo;
            }
            else
            {
                var geo = new EsriJsonPoint(Content).ToGeometry();
                GeometryType = geo.GeometryType;
                return geo;
            }
        }
    }
}
